package Components
{
	import nl.jorisdormans.phantom2D.objects.GameObject;
	import nl.jorisdormans.phantom2D.objects.GameObjectComponent;
	import nl.jorisdormans.phantom2D.objects.ICollisionHandler;
	/**
	 * ...
	 * @author Sebastiaan
	 */
	public class CauseDamage extends GameObjectComponent implements ICollisionHandler
	{
		public static const M_DAMAGE:String = "damage";
		
		public var owner : GameObject;
		
		public function CauseDamage(ownser : GameObject) 
		{
			this.owner = owner;
		}
		
		public function canCollideWith(other:GameObject):Boolean
		{
			if (other == owner)
				return false;
				
			return true;
		}
		
		/* INTERFACE nl.jorisdormans.phantom2D.objects.ICollisionHandler */
		
		public function afterCollisionWith(other:GameObject):void
		{
			other.sendMessage(M_DAMAGE);
		}
	}

}